home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000078_icon-group-sender _Tue Apr 5 07:32:34 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
1KB
Received: by cheltenham.cs.arizona.edu; Tue, 5 Apr 1994 09:01:18 MST
Via: uk.ac.edinburgh.festival; Tue, 5 Apr 1994 15:31:10 +0100
Date: 05 Apr 94 15:30:59 BST
From: R J Hare <rjhare@festival.ed.ac.uk>
Subject: 2-darrays
To: icon-group@cs.arizona.edu
Organisation: Edinburgh University Computing Service
Message-Id: <9404051531.aa04767@uk.ac.ed.festival>
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
The method on p52 of the the 1st edition of the Icon book (all I have to hand
at the moment) uses lists of lists:
procedure array(i,j,x)
a:=list(i,0)
k:=0
while a[k +:= 1] := list(j,x)
return a
end
I think I'd do it like this (in fact I have done and it seems to work) - to me
this is easier to read than the first version:
procedure array(i,j,x)
a:=list(i)
every !a=list(j,x)
return a
end
So:
shogiboard:=array(9,9," ")
would return an empty 9x9 board.
You refer to eleents of the array as a[i][j] - later versions of Icon allow
a[i,j].
Roger Hare.